<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Image annotation</title>
<script language="javascript" src="js/prototype.js" > </script>
<script language="javascript" src="js/webtoolkit.cookies.js" > </script>

<script language="javascript" src="js/mt.js" > </script>

<script language="javascript">AC_FL_RunContent = 0;</script>
<script language="javascript" src="js/AC_RunActiveContent.js" language="javascript"></script>
<script language="javascript" src="js/flash_ui.js" language="javascript"></script>


</head>



<body bgcolor="#ffffff">


<form id="MT_form" name="MT_form" action="http://www.mturk.com/mturk/externalSubmit" method="POST">
<div id="instructions_div">
IMPORTANT: Read the <a id="a_instructions" href="instructions.html" target="wnd_instructions">instructions</a>!! <!--<b>Instructions have been updated!</b><br/>-->
</div>

<div id="feedback_div" ></div>

<div id="existing_comments_div" style="display:none;"></div>


<table><tr><td>
<div id="flash_div"></div>
</td><td>
<a id='help_frame_ref' target="_blank" href="#">Open help chat in a new window</a><br/>

<iframe id='help_frame' src="" style="width:250px;height:440px;" scrolling="no" allowtransparency="true" border="0" frameborder="0" ></iframe>
<br/><a href="#" onclick="return hide_chat()">hide chat </a> / <a href="#" onclick="return show_chat()">show chat</a>

</td></tr></table>
<noscript>
Error. Javascript is required.
</noscript>

<div id="comments_form_div">
<hr/>
Any comments/suggestions/etc: <input type=text name="Comments" id="Comments" value="" onKeyPress="return disableEnterKey(event)">
<hr/>
<b>Config:</b>(make sure the cookies are enabled):<br/>
UI scale: 
<a href="#" onclick="scale_flash_ui(annotation_gui,0.5);return false;">x0.5</a> |
<a href="#" onclick="scale_flash_ui(annotation_gui,1);return false;">x1 </a> |
<a href="#" onclick="scale_flash_ui(annotation_gui,1.5);return false;">x1.5 </a> |
<a href="#" onclick="scale_flash_ui(annotation_gui,2);return false;">x2</a> |
<a href="#" onclick="scale_flash_ui(annotation_gui,3);return false;">x3</a> |
<a href="#" onclick="scale_flash_ui(annotation_gui,4);return false;">x4</a> <br/>
<hr/>

</div>
<input type=hidden name="assignmentId" id="assignmentId" value="">
<input type=hidden name="hitId" id="hitId" value="ignored">
<input type=hidden name="sites" id="sites" value="">
<input type=hidden name="extid" id="extid" value="">
<input type=hidden name="session" id="session" value="">
<input type=hidden name="workerId" id="workerId" value="">
<input type=hidden name="mode" id="mode" value="">

<input type=hidden name="load_time" id="load_time" value="">
<input type=hidden name="submit_time" id="submit_time" value="">

</form>





<script language="javascript">


var run_submit=function (){
    if (gup('assignmentId') == "ASSIGNMENT_ID_NOT_AVAILABLE")
{
 alert("You must accept the task first");
}else{
  var now=new Date();
  $('submit_time').value=now.toUTCString();
  $('MT_form').submit();
}
}

    //
    // Check if the worker is PREVIEWING the HIT or if they've ACCEPTED the HIT
    //
    mode_value="AmazonMTproduction"

    if (gup('assignmentId') == "ASSIGNMENT_ID_NOT_AVAILABLE")
    {
        mode_value=="AmazonMTproduction"
        // If we're previewing, the flash interface checks that.
    } else {
        var form = document.getElementById('MT_form');
        if (document.referrer && ( document.referrer.indexOf('workersandbox') != -1) ) {
            form.action = "http://workersandbox.mturk.com/mturk/externalSubmit";
	    mode_value="AmazonMTsandbox";
        }
    }

//PARSE arguments

    query_args=document.location.toString();
    query_args=query_args.split("?")[1];
    args_list=query_args.split("&");
    swf=""
    swf_w='600';
    swf_h='400';
    display_mode="";
    existing_comments="";
    no_mode_in_query=1;
    task_id='generic';


for (i = 0; i <= args_list.length; i++)
{
	arg=args_list[i];
	if(arg){
	arg_pair=arg.split("=");
	arg_n=arg_pair[0];
	arg_v=arg_pair[1];
	if( arg_n=="assignmentId"){
		$('MT_form')[arg_n].value=arg_v;
	}else if( arg_n=="hitId"){
		$('MT_form')[arg_n].value=arg_v;
	}else if( arg_n=="workerId"){
		$('MT_form')[arg_n].value=arg_v;
	}else if( arg_n=="extid"){
	        $('MT_form')[arg_n].value=arg_v;
	}else if( arg_n=="session"){
	        $('MT_form')[arg_n].value=arg_v;
	}else if( arg_n=="swf"){
	        swf=arg_v;
	}else if( arg_n=="swf"){
	        swf=arg_v;
	}else if( arg_n=="swf_w"){
	        swf_w=arg_v;
	}else if( arg_n=="swf_h"){
	        swf_h=arg_v;
	}else if( arg_n=="mode"){
	        no_mode_in_query=0;
		$('MT_form')[arg_n].value=arg_v;
		mode_value=arg_v;
	}else if( arg_n=="display_mode"){
	        display_mode=arg_v;
	}else if( arg_n=="comments"){
	        existing_comments=arg_v;
	}else if( arg_n=="task"){
	        task_id=arg_v;

        }
	}
}

var Cookies = new CookieHandler();
var show_gchat = Cookies.getCookie('show_gchat'); // get cookie
if (typeof(show_gchat) == 'undefined' || show_gchat==null) 
{
show_gchat=1;
Cookies.setCookie('show_gchat', show_gchat, 30*60*60); // set cookie for 1 month
}

if(show_gchat==1)
{
$('help_frame').src='http://www.google.com/friendconnect/discuss?scope=web&topic='+task_id+'%3A%20clarifications%3A(MechTurk)';
$('help_frame').style.display='block';
}else{
$('help_frame').style.display='none';
}

$('help_frame_ref').href='http://www.google.com/friendconnect/discuss?scope=web&topic='+task_id+'%3A%20clarifications%3A(MechTurk)';

if( display_mode=="thumbnail"){
    $('instructions_div').style.display='none';
    $('comments_form_div').style.display='none';
    $('help_frame').style.display='none';
    $('help_frame_ref').style.display='none';
}
if( mode_value=="display"){
    $('help_frame').style.display='none';
    $('help_frame_ref').style.display='none';
}

if( existing_comments != "")
{
    d=$('existing_comments_div');
    d.innerHTML="<b>Comments:</b>"+existing_comments;
    d.style.display="block";
}

instructions_URL=unescape(gup("instructions"));
$('a_instructions').href=instructions_URL;

if ( no_mode_in_query){
    query_args=query_args+"&mode="+mode_value
}



submitURL="";
if(mode_value=="AmazonMTsandbox"){
	submitURL="http://workersandbox.mturk.com/mturk/externalSubmit";
}else if(mode_value=="AmazonMTproduction"){
	submitURL="http://www.mturk.com/mturk/externalSubmit";
}else if(mode_value=="MT2"){
	submitURL="/mt/submit/";
}else if(mode_value=="edit"){
	submitURL="/mt/submit/";
}else if(mode_value=="input"){
	submitURL="/mt/submit/";
}else if(mode_value=="sandbox2"){
	submitURL="/mt/submit/";
}

feedback_url=gup("feedback_url");
if(feedback_url != "")
{
    new Ajax.Updater('feedback_div',feedback_url);
}

param_submit_url=gup("submit_url");
if(param_submit_url!="")
{
    $('MT_form').action=param_submit_url;
}
else
{
    $('MT_form').action=submitURL;
}

var now = new Date();
$('load_time').value=now.toUTCString();

var persistent_ui_scale = get_persistent_value('ui_scale',1);
create_flash_interface(swf,swf_w*persistent_ui_scale,swf_h*persistent_ui_scale,query_args);


var hide_chat = function()
{
  show_gchat = 0;
  Cookies.setCookie('show_gchat', show_gchat, 30*60*60); // set cookie for 1 month
  $('help_frame').src=""
  $('help_frame').style.display="none"
}

var show_chat = function()
{
show_gchat = 1;
Cookies.setCookie('show_gchat', show_gchat, 30*60*60); // set cookie for 1 month
$('help_frame').src='http://www.google.com/friendconnect/discuss?scope=web&topic='+task_id+'%3A%20clarifications%3A(MechTurk)'
$('help_frame').style.display="block"
}
</script></body>
</html>
